/*
 * Title: WADS
 * Description: Web-based Auto flow Documents System
 * Copyright: 2007
 * Company: CoE
 * @author: Mr.Nattasan Wang-Aphisit
 * @version 1.1
 */

package wads.com;

import java.io.Serializable;
import java.util.Date;
import java.util.Vector;

final public class DocumentTemplateInfo implements Serializable {
//  private static final long serialVersionUID = 2858381041786842750L;

  private String template_ID;
  private String template_Name;
  private Vector<String> flow_Users;
  private boolean need_SaveToDB;
  private Date created_Date;
  private int templateStatus;

  public DocumentTemplateInfo(String template_ID, String template_Name) {
    this.template_ID = template_ID;
    this.template_Name = template_Name;
    this.created_Date = new Date(); //get current time
    this.flow_Users = new Vector<String>();
    this.templateStatus = 1;
  }

  public void add_nextUser_to_Flow(String usrName){
    this.flow_Users.add(usrName);
  }
  
  public String whois_nextUser_from_thisUser(String usrName){
    int index = this.flow_Users.indexOf(usrName);
    if(index < 0 || (index + 1) >= this.flow_Users.size())
      return null;
    else
      return (String)flow_Users.elementAt(index + 1);
  }

  public String whois_lastUser_from_thisUser(String usrName){
    int index = this.flow_Users.indexOf(usrName);
    if(index < 0 || (index - 1) <= 0)
      return null;
    else
      return (String)flow_Users.elementAt(index - 1);
  }

  public boolean isLastUser_in_Flow(String usrName){
    return flow_Users.lastElement().equals(usrName);
  }

  public String getFirstUser(){
    return (String)flow_Users.firstElement();
  }

  public String getTemplate_ID() {
    return template_ID;
  }
  public String getTemplate_Name() {
    return template_Name;
  }
  public Vector getFlow_Users() {
    return flow_Users;
  }
  public void setNeed_SaveToDB(boolean newNeed_SaveToDB) {
    need_SaveToDB = newNeed_SaveToDB;
  }
  public boolean isNeed_SaveToDB() {
    return need_SaveToDB;
  }
  public Date getCreated_Date() {
    return created_Date;
  }
  public void setTemplateStatus(int ts){
    templateStatus = ts;
  }
  public int getTemplateStatus(){
    return templateStatus;
  }
}